<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>卡信息</title>
<link rel="stylesheet" type="text/css" href="admin/css/style.css" />
<link rel="stylesheet" type="text/css" media="all" href="admin/css/niceforms-default.css" />
<link rel="stylesheet" type="text/css" media="all" href="admin/js/date/jquery-ui-1.8.16.custom.css" />
<script type="text/javascript" src="admin/js/jquery.min.js"></script>
<script type="text/javascript" src="admin/js/niceforms.js"></script>
<script type="text/javascript" src="admin/js/ddaccordion.js"></script>
<script type="text/javascript" src="admin/js/jconfirmaction.jquery.js"></script>
<script type="text/javascript" src="admin/js/jquery.jclock-1.2.0.js"></script>
<script type="text/javascript" src="admin/js/date/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="admin/js/date/jquery.ui.datepicker-zh-CN.js"></script>

<script type="text/javascript">
ddaccordion.init({
	headerclass: "submenuheader", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [1], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "<img src='<%=basePath%>admin/images/plus.gif' class='statusicon' />", "<img src='<%=basePath%>admin/images/minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
});
</script>
<script type="text/javascript">
	
	$(function() {
	    $('.jclock').jclock();
	});
	
	
</script>
<script>
	$(function() {
		var msg = "<s:property value='msg' />";
		if(msg != '') {
			alert(msg);
		}
		
		$( "#dialog-reset" ).dialog({
			autoOpen: false,
			height: 300,
			width: 660,
			modal: true,
			buttons: {
				"提交": function() {
					var passwd = $("#passwd").val();
					var m=/\d{6}/;
					if(!m.test(passwd))
				    {
						if(passwd.trim()!=""){				    	
					 		alert("请输入6位数密码");
					 		return;
					 	}
				 	}
					
					$.post("cardAction!resetPasswd", $("#resetForm").serialize(), function(data){
						eval('var d='+data);
						if(d.result=='success'){
	 						$("#dialog-reset").dialog( "close" );
	 						alert("重置成功");
						}else{
							alert("重置出错，请稍后再试");
						}
					});		
				},
				"取消": function() {
					$( this ).dialog( "close" );
				}
			},
			close: function() {
			}
		});
		
		
		$( "#dialog-singleExpense" ).dialog({
			autoOpen: false,
			height: 150,
			width: 660,
			modal: true,
			buttons: {
				"提交": function() {
					var expense = $("#expense").val();
					var m=/\d+/;
					if(!m.test(expense))
				    {
				 		alert("请输入正确的数值");
				 		$("#expense").val('${account.singleExpense}');
			 			return;
				 	}else if(expense > parseInt('<s:property value="account.singleExpense" />')){
						var isExe = confirm("您所输入的额度大于原本的值,是否确定更改?");
						if(!isExe)
							return ;
				 	}
					$.post("accountAction!mofifyAccountSingleExpenseAction", $("#expenseForm").serialize(), function(data){
						eval('var d='+data);
						if(d.result=='success'){
	 						$("#dialog-singleExpense").dialog( "close" );
	 						alert("修改成功");
	 						window.location.reload();
						}else{
							alert("修改出错，请稍后再试");
						}
					});		
					
				},
				"取消": function() {
					$( this ).dialog( "close" );
				}
			},
			close: function() {
			}
		});
	
		
		$( "#dialog-status" ).dialog({
			autoOpen: false,
			height: 200,
			width: 660,
			modal: true,
			buttons: {
				"提交": function() {
					var status = $("#resetForm input:radio[checked]").val();
					$.post("cardAction!updateStatus", $("#statusForm").serialize(), function(data){
						eval('var d='+data);
						if(d.result=='success'){
	 						alert("更改成功");
						}else if(d.result="abnormal"){
							alert("您的账户处于异常状态，或者您还未修改卡信息，请前行处理");
						}else{
							alert("重置出错，请稍后再试");
						}
 						$("#dialog-status").dialog( "close" );
 						window.location.reload();
					});		
				},
				"取消": function() {
					$( this ).dialog( "close" );
					window.location.reload();
				}
			},
			close: function() {
			}
		});
		
	});
	

	function resetPasswd(id, no) {
		$("#cardId").val(id);
		$("#cardNo").val(no);
		$("#dialog-reset").dialog("open");
	}
	
	function changeStatus(id,status){
	
	
		$("#cardIdForStatus").val(id);
		if(status=='1'){
			$("#tr3").attr("style","");
			$("#td3").html("冻结");
			$("#tr4").attr("style","");
			$("#td4").html("挂失");
		}else if(status=='2' || status=='6'){
			$("#tr1").attr("style","");
			$("#td1").html("激活");
		}else if(status=='3'){
			$("#tr1").attr("style","");
			$("#td1").html("解冻");
		}else if(status=='4'){
			$("#tr5").attr("style","");
			$("#td5").html("注销");
		}else if(status=='5'){
			$("#tr6").attr("style","");
			$("#td6").html("补卡");
		}
		
		$("#dialog-status").dialog("open");
	}
	
	function changExpense(){
		$("#dialog-singleExpense").dialog("open");
	}
	
	function firstPage() {
		window.location='cardAction!getCardByAccountIdAction?accountId=<s:property value="account.accountId" />&currentPage='+1;
	}
	
	function lastPage() {
		var currentPage = "<s:property value='pager.totalPage' />";
		window.location='cardAction!getCardByAccountIdAction?accountId=<s:property value="account.accountId" />&currentPage='+currentPage;
	}
	
	function backPage() {
		var currentPage = "<s:property value='pager.currentPage' />";
		currentPage = parseInt(currentPage)-1;
		window.location='cardAction!getCardByAccountIdAction?accountId=<s:property value="account.accountId" />&currentPage='+currentPage;
	}
	
	function nextPage() {
		var currentPage = "<s:property value='pager.currentPage' />";
		currentPage = parseInt(currentPage)+1;
		window.location='cardAction!getCardByAccountIdAction?accountId=<s:property value="account.accountId" />&currentPage='+currentPage;
	}
	
	function goPage() {
		var goPage = Number($('#goPage').attr('value'));
		if(isNaN(goPage)) {
			$('#goPage').attr('value', '');
			return;
		}
		window.location='cardAction!getCardByAccountIdAction?accountId=<s:property value="account.accountId" />&currentPage='+goPage;
	}
	
	
	function attachCard(){
		window.location="cardAction!toAttachAddPage?accountId=${account.accountId}";
	}
	
</script>

</head>

<body>
<div id="main_container">
	<%@include file="../header.jsp"%>
    <div class="main_content">
		<%@include file="menu.jsp"%>
   		<div class="center_content">  
  			<div class="left_content">
				<%@include file="sidebarmenu_sys.jsp"%>
    	  	</div>  
    
		    <div class="right_content">            
		        
		      	<h5>当前位置: 卡系统 &gt; 卡管理</h5>
				<!-- dialog -->
				<div id="dialog-reset" title="重置密码">
			      	<form action="#" id="resetForm"
								name="resetForm" method="post">
						<table id="rounded-corner">
							<tbody>
										<tr>
											<td align="right">卡号</td>
											<td align="left" >
												<input type="text" disabled="disabled" id="cardNo" />
											</td>
											<td><input type="hidden" name="cardId" id="cardId"/></td>
										</tr>
										<tr>
											<td align="right">新密码</td>
											<td align="left" id="cardId">
												<input type="text" name="passwd" id="passwd" maxlength="6" />
											</td>
											<td align="left"><span class="error">不输入，默认系统自动生成</span></td>
										</tr>
							</tbody>
						</table>
					</form>
				</div>
				
				
				
				<div id="dialog-singleExpense" title="修改">
			      	<form action="#" id="expenseForm"
								name="expenseForm" method="post">
						<table id="rounded-corner">
							<tbody>
										<tr>
											<td align="right">单次限额：</td>
											<td align="left" >
												<input type="text"  id='expense' value='${account.singleExpense}' name="account.singleExpense" onclick="javascipt:$('#expense').val('');"/>
											</td>
											<td><input type="hidden" name="accountId" value='${account.accountId }'/></td>
										</tr>
							</tbody>
						</table>
					</form>
				</div>
				
		      	
				
		      	
		      	<div id="dialog-status" title="更改状态">
			      	<form action="#" id="statusForm"
								name="statusForm" method="post">
						<table id="rounded-corner">
							<tbody>
								<c:forEach items="${dics.DIC_CARD_STATUS}" var="item">
										<tr id="tr${item.value}" style="display: none;">
											<td align="right"><input type="radio" name="status" value="${item.value}"/></td>
											<td align="left" id="td${item.value}">
												${item.name} || ${account.accountId }
											</td>
										</tr>
								</c:forEach>
							</tbody>
						</table>
						<input type="hidden" id="cardIdForStatus" name="cardId"/>
						<input type="hidden" value="${account.accountId }" name="accountId"/>
					</form>
				</div>
		      	
		      	<!-- dialog -->
		      	
		      	
				
				<table id="rounded-corner" summary="2007 Major IT Companies' Profit">
				    <thead>
				    	<tr>
				        	<th scope="col" class="rounded-company" width="20%"></th>
				            <th scope="col" class="rounded" width="15%"></th>
				            <th scope="col" class="rounded" width="20%" align="right">账户信息</th>
				            <th scope="col" class="rounded" width="15%"></th>
				            <th scope="col" class="rounded" width="20%"><!--<input type="button" value="添加副卡" onclick="attachCard();"/>
				            	--><a href="javascript:attachCard();" class="bt_blue">
		         					</span><strong>添加副卡</strong>
		        				</a>
				            </th>
				            <th scope="col" class="rounded-q4" width="10%"></th>
				        </tr>
				    </thead>
			        <tfoot>
			    		<tr>
			    			<td  class="rounded-foot-left"></td>
				        	<td></td>
				            <td>
				            </td>
				            <td>
				            </td>
				        	<td></td>
				        	<td class="rounded-foot-right">&nbsp;</td>
				        </tr>
				    </tfoot>
				    <tbody>
				    	<tr>
				            <td align="right">客户名称：</td>
				            <td align="left"><s:property value="account.customer.name" /> </td>
				            <td align="right">账户名称：</td>
				            <td align="left"><s:property value="account.name" /> </td>
				            <td align="right">信用额度：</td>
				            <td align="left"><s:property value="account.creditAmount" /> </td>
				        </tr>   
				        <tr>
				            <td align="right">账户余额：</td>
				            <td align="left"><s:property value="account.balance" /> </td>
				            <td align="right">信用余额：</td>
							<td align="left"><s:property value="account.creditLeft" /> </td>		
				            <td align="right">单次限额：</td>
							<td align="left"><s:property value="account.singleExpense" /> </td>		
				        </tr>  
				        <tr>
				        	 <td align="right">余额不足提醒：</td>
				            <td align="left"><s:property value="account.balanceWarm()" /> </td>
				            <td align="right">描述：</td>
							<td align="left"><s:property value="account.accountDesc" /> </td>		
				            <td align="right"><input type="hidden" name="currentPage"/></td>
							<td align="left"></td>		
				        </tr> 
				    </tbody>
				</table>
		           
		        <s:if test="pager.list.size() != 0">        
				<table id="rounded-corner" summary="2007 Major IT Companies' Profit">
				    <thead>
				    	<tr>
				    		
				            <th scope="col" class="rounded-company" width="5%">序号</th>
				            <th scope="col" class="rounded" width="25%">卡号</th>
				            <th scope="col" class="rounded" width="25%">批次号</th>
				            <th scope="col" class="rounded" width="10%">状态</th>
				            <th scope="col" class="rounded" width="10%">类型</th>
				            <th scope="col" class="rounded" width="5%">标记</th>
				            <th scope="col" class="rounded-q4" width="20%">操作</th>
				        </tr>
				    </thead>
			        <tfoot>
			    		<tr>
				        	<td class="rounded-foot-left" colspan="3">
				        	<div class="pager">
					     		共<s:property value="pager.totalSize" />条记录，
					     		当前第<s:property value="pager.currentPage" /> / <s:property value="pager.totalPage" />页
		     				</div>
				        	</td>
				        	
				        	<td colspan="4">
				        		<div class="goPage">
									<a href="javascript:firstPage();">|&lt;&lt; first</a>
									<a href="javascript:backPage();"><span>&lt;&lt; prev</span></a>
									<a href="javascript:void(0)"><input type="text" name="goPage" id="goPage" value="" size="2" maxlength="4" onblur="goPage();" /></a>
									<a href="javascript:nextPage();">next &gt;&gt;</a>
									<a href="javascript:lastPage();">last &gt;&gt;|</a>
						        </div>
				        	</td>
				        	<td class="rounded-foot-right">&nbsp;</td>
				        </tr>
				    </tfoot>
				    <tbody>
				    	<s:iterator value="pager.list" status="status">
				    	<tr>
				        	<td><s:property value="#status.index+1" /></td>
				            <td><s:property value="cardNo" /></td>
				            <td><s:property value="batchNo" /></td>
				            <td><s:property value="statusString()" /></td>
				            <td><s:property value="useTypeString()" /></td>
				            <td><s:property value="markString()" /></td>
				            <td><a href="javascript:resetPasswd('<s:property value="cardId" />','<s:property value="cardNo" />');">重置密码</a> 
				            	<a href="javascript:changExpense();">修改</a>
				            	<a href='cardAction!getCardRecordAction?accountId=<s:property value="accountId" />'>历史</a>
				            	<a href="javascript:changeStatus('<s:property value="cardId" />','<s:property value="status" />');">更改状态</a>
				            </td>
				        </tr>
				        </s:iterator>
				    </tbody>
				</table>
		        </s:if> 
		        <s:else>
		        	<span class="error"><s:fielderror fieldName="msg"></s:fielderror></span>
		        </s:else>
		     
			</div>  <!-- end of right content-->
                    
		</div>  <!--end of center content -->               
    
		<div class="clear"></div>
	
    </div>  <!--end of main content-->
	
    
    <%@include file="../footer.jsp" %>

</div>		
</body>
</html>